{% extends 'index.html' %}
{% load static %}

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>title</title>
    <link href="{% static 'css/common.css' %}" rel="stylesheet">

</head>

<body>

{% block title %}
    <span class="navbar-page-title"> 军事需求知识百科 - 需求百科 </span>
{% endblock %}


{% block content %}
    <div class='container-fluid'>
        <!-- 添加记录 -->
        <form action="{% url 'search_require_wikipedia' %}">
            <button class='my-btn' type="submit" style="float: right;margin:0 10px 0 20px">搜索</button>
            <input type="text" name="search_name" id="search_name" class="form-control my-input" placeholder="需求百科名称" style="width:115px;float: right;">
        </form>

        <!-- 模板选择框 -->
        <form action="" method="post">
            <span style="margin: 0 10px 0 10px">模板选择</span>
            <select id="template_choiced" class="form-control my-select" style="display: inline;width: auto;margin-right: 30px" name="template_choiced">
                {% for sg_tem in template_name_list %}
                    <option value="{{ sg_tem.id }}">{{ sg_tem.name }}</option>
                {% endfor %}
            </select>

            <!-- 知识卡片选择框 -->
            <span style="margin: 0 10px 0 10px">知识卡片选择</span>
            <select id="knowledge_card_choiced" class="form-control my-select" style="display: inline;width: auto;margin-right: 30px" name="knowledge_card_choiced">
                {% for sg_card in card_name_list %}
                    <option value="{{ sg_card.id }}">{{ sg_card.name }}</option>
                {% endfor %}
            </select>
            <button class='my-btn' type="submit">添加</button>
        </form>

        <p></p>

        <div class="form-group" style="margin: 10px 10px;padding: 10px; background-color: #ffffff">
            <!-- 页面信息展示 -->
            <table style="width: 100%" class="my-table">
                <thead>
                <tr>
                    <th style="width:5%;text-align: center;">序号</th>
                    <th style="width:20%;text-align: center;">百科名称</th>
                    <th style="width:50%;text-align: center;">创建时间</th>
                    <th style="width:20%;text-align: center;">操作</th>
                </tr>
                </thead>
                <tbody>
                {% for single_data in res_data %}
                    <tr style="text-align: center">
                        <td>{{ forloop.counter }}</td>
                        <td>{{ single_data.name }}</td>
                        <td>{{ single_data.create_time|date:"Y-m-d H:i:s" }}</td>
                        <td>
                            <button class="my-btn" onclick="javascript:location.href='{% url 'edit_require_wikipedia' single_data.id %}'">编辑</button>

{#                            <a style="padding: 9px 10px" href="{% url 'edit_require_wikipedia' single_data.id %}"#}
{#                               class="my-btn-a my-btn">编辑</a>#}
                            <button class="my-btn" onclick="model_del({{ single_data.id }})">删除</button>
                            <button class="my-btn" onclick="javascript:location.href='{% url 'preview_require_wikipedia' single_data.id %}'">预览</button>

{#                            <a style="padding: 9px 10px" href="{% url 'preview_require_wikipedia' single_data.id %}" class="my-btn-a my-btn">预览</a>#}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}

{% block myjs %}
    <script>
        document.getElementById("jsxqzsbk").style.display = 'block';
        document.getElementById("xqbk").style.backgroundColor = 'rgba(30,21,21,0.44)';

        /**
         * 删除数据
         */
        function model_del(id) {
            // 生成路径
            var url = "{% url 'delete_require_wikipedia' 0  %}";
            url = url.replace(/0/, id);
            // 确认框
            zdconfirm('系统确认框', '你确认删除该条数据吗？', r => r ? window.location.href = url : '');
        }


    </script>
{% endblock %}


</body>

</html>